{% extends 'base.html' %}
{% load static %}

{% block title %}网上商城-商品详情{% endblock title %}

{% block content %}

	{% include 'header-con.html' %}

	{% include 'search-bar.html' %}

	{% include 'navbar-con.html' %}

	<div class="goods_detail_con clearfix">
		<div class="goods_detail_pic fl"><img style="width:350px;height:350px;margin:24px 0 0 24px;" src="{{ goods.image.url }}"></div>
        <form action="/order/place/dir/" method="post">
            	{% csrf_token %}
            <div class="goods_detail_list fr">
                <input type="hidden" id="good_id" value="{{ goods.id }}" name="good_id">
                <h3>{{ goods.name }}</h3>
                <p>{{ goods.desc }}</p>
                <div class="prize_bar">
                    <span class="show_pirze">¥<em>{{ goods.price }}</em></span>
                    <span class="show_unit">单  位：{{ goods.unite }}</span>
                </div>
                <div class="goods_num clearfix">
                    <div class="num_name fl">数 量：</div>
                    <div class="num_add fl">
                        <input type="text" class="num_show fl" value="1" name="num_show">
                        <a href="javascript:;" class="add fr">+</a>
                        <a href="javascript:;" class="minus fr">-</a>
                    </div>
                </div>
                <div>
                    <p>销量:<span style="margin-left: 40px;">{{goods.sales}}</span></p>
                </div>
                <div class="total">总价：<em>{{ goods.price }}元</em></div>
                <div class="operate_btn">
                    <input class="buy_btn" type="submit" value="立即购买">
                    <a href="javascript:" class="add_cart" id="add_cart">加入购物车</a>
                </div>
            </div>
        </form>
	</div>

	<div class="main_wrap clearfix">
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
					{% for new_good in new_products %}
					<li>
						<a href="/goods/detail/{{ new_good.id }}/"><img src="{{ new_good.image.url }}"></a>
						<h4><a href="/goods/detail/{{ new_good.id }}/">{{ new_good.name }}</a></h4>
						<div class="prize">￥{{ new_good.price }}</div>
					</li>
					{% endfor %}
				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<ul class="detail_tab clearfix">
				<li id="tag_detail" class="active">商品介绍</li>
				<li id="tag_comment">评论</li>
			</ul>

			<div class="tab_content" id="tab_detail">
				<dl>
					<dt>商品详情：</dt>
					<dd>{{ goods.detail | safe }} </dd>
				</dl>
			</div>

			<div class="tab_content" id="tab_comment" style="display: none">
				<dl>
                    {% for order in order_goods %}
					<dt>用户名:{{ order.order_info.user.username }}   |   评论时间：{{ order.update_time |date:"Y-m-d H:i:s" }}&nbsp;&nbsp;</dt>
                    <dd>评论内容:{{ order.comment }}</dd>
                    {% endfor %}
				</dl>
			</div>

		</div>
	</div>




	<div class="add_jump"></div>

	<script type="text/javascript" src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
	<script type="text/javascript" src="{% static 'js/detail.js' %}"></script>
{% if stock < total_count %}
    <script>
        alert('库存不足');
    </script>
{% endif %}
{% endblock content %}
